package com.topView2;

/**
 * @Author: huangzhigao
 * @Date: 2023/2/12 16:52
 */
public class leecode75 {
    public void sortColors(int[] nums) {
        int left = 0;
        int right = nums.length;
        int index = left;
        while (index < right) {
            if (nums[index] < 1) {
                swap(nums, left++, index++);
            } else if (nums[index] > 1) {
                swap(nums, index, --right);
            } else {
                index++;
            }
        }
    }


    public void swap(int[] nums, int i, int j) {
        int tmp = nums[i];
        nums[i] = nums[j];
        nums[j] = tmp;
    }
}
